package com.glory.dgcpcpda.activity;


import android.content.res.Resources;
import android.os.Build;
import android.util.Log;

import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;

import com.glory.dgcpcpda.R;
import com.glory.dgcpcpda.base.BaseActivity;
import com.glory.dgcpcpda.base.Constant;
import com.glory.dgcpcpda.entity.AuthorityListEntity;
import com.glory.dgcpcpda.fragment.MainFragment;
import com.glory.dgcpcpda.fragment.SearchFragment;
import com.pda.platform.ui.ui_pdaplatform.entity.FreeUI_AddViewEntity;
import com.pda.platform.ui.ui_pdaplatform.entity.FreeUI_TabEntity;
import com.pda.platform.ui.ui_pdaplatform.tablayout.CommonTabLayout;
import com.pda.platform.ui.ui_pdaplatform.tablayout.listener.CustomTabEntity;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_ActivityManager;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Consumer;

import butterknife.BindView;

public class MainActivity extends BaseActivity {
    @BindView(R.id.tabLayout)
    CommonTabLayout tabLayout;

    private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
    private ArrayList<Fragment> mFragments = new ArrayList<>();

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initView() {
        Constant.AUTHORITY_LIST.clear();
    }


    @RequiresApi(api = Build.VERSION_CODES.N)
    @Override
    protected void initData() {
        initAuthorityList();
        Resources resources = getResources();
        mFragments.add(new MainFragment());
        mTabEntities.add(new FreeUI_TabEntity("主界面",
                resources.getDrawable(R.drawable.home_index_select), resources.getDrawable(R.drawable.home_index_normal)));
//        mFragments.add(new SearchFragment());
//        mTabEntities.add(new FreeUI_TabEntity("查询",
//                resources.getDrawable(R.drawable.home_search_select), resources.getDrawable(R.drawable.home_search_normal)));
        tabLayout.setTabData(mTabEntities, this, R.id.content, mFragments);

    }

    @RequiresApi(api = Build.VERSION_CODES.N)
    private void initAuthorityList() {
        for (AuthorityListEntity.Authority authority : Constant.AUTHORITY_ENTITY.getAUTHORITYLIST()){
            Constant.AUTHORITY_LIST.add(authority.getNAME());
        }

    }

    @Override
    protected FreeUI_AddViewEntity getBaseEntity() {
        return null;
    }
}
